package com.love.netty.demo.handler.response;

import com.love.netty.core.packet.response.MessageResponsePacket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.text.SimpleDateFormat;

/**
 * @ClassName: MessageResponseHandler
 * @Description:
 * @Author: wuj
 * @Date: 2021-06-24 15:00
 **/
public class MessageResponseHandler extends SimpleChannelInboundHandler<MessageResponsePacket> {

    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, MessageResponsePacket messageResponsePacket) throws Exception {
        String fromUserId = messageResponsePacket.getFromUserId();
        String fromUserName = messageResponsePacket.getFromUserName();
        System.out.println(fromUserId + ":" + fromUserName + " -> " + messageResponsePacket.getMessage());
    }
}
